﻿<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>DR钻戒后台管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script src="../js/jquery-1.12.4.js"></script>
</head>

<script type="text/javascript">

    function UpdateAdminInfo(id){
        let adminName=$("#userName").val();
        let adminsex=$("#select").val();
        let adminBrithday=$("#data").val();
        let adminPhone=$("#userphone").val();
        let adminAdeessr=$("#userAddress").val();

        if ($('#userName').val() == ''||$('#userName').val() == null) {
            alert("请填写用户名!")
            return false;
        }

        if ($('#select').val() == ''||$('#select').val() == null) {
            alert("请选择性别!")
            return false;
        }

        if ($('#data').val() == ''||$('#data').val() == null) {
            alert("请填写出生日期!")
            return false;
        }

        if ($('#userphone').val() == ''||$('#userphone').val() == null) {
            alert("请填写联系电话!")
            return false;
        }

        if ($('#userAddress').val() == ''||$('#userAddress').val() == null) {
            alert("请填写用户地址!")
            return false;
        }

       $.getJSON("http://localhost:8080/DiamondRing/BackUpdateAdminInfoServlet","ID="+id+"&adminName="+adminName+"&adminsex="+adminsex+"&adminBrithday="+adminBrithday+"&adminPhone="+adminPhone+"&adminAdeessr="+adminAdeessr,function (data) {
            if (data>0){
                alert("保存成功!");
                location.href="http://localhost:8080/DiamondRing/back-stage-Management/userList.html";
            }else{
                alert("保存失败!");
            }
       })
    }

    $(function () {
        let id=sessionStorage.getItem("Id")
        $.getJSON("http://localhost:8080/DiamondRing/LookAdminInfoServlet","ID="+id,function (data) {
            $.each(data, function () {
                let sex;
                let sex2;
                if (this.sex=="男"){
                    sex="男";
                    sex2="女";
                }else{
                    sex="女";
                    sex2="男";
                }
                $(".providerAdd").append(" <form action=\"#\">\n" +
                    "                <!--div的class 为error是验证错误，ok是验证成功-->\n" +
                    "                <div>\n" +
                    "                    <label for=\"userName\">用户名称：</label>\n" +
                    "                    <input type=\"text\" name=\"userName\" id=\"userName\" placeholder=\""+this.name+"\"/>\n" +
                    "                    <span >*</span>\n" +
                    "                </div>\n" +
                    "\n" +
                    "                <div>\n" +
                    "                    <label >用户性别：</label>\n" +
                    "\n" +
                    "                    <select name=\"\" id=\"select\">\n" +
                    "                        <option value=\""+sex+"\" selected >"+sex+"</option>\n" +
                    "                        <option value=\""+sex2+"\">"+sex2+"</option>\n" +
                    "                    </select>\n" +
                    "                </div>\n" +
                    "                <div>\n" +
                    "                    <label for=\"data\">出生日期：</label>\n" +
                    "                    <input type=\"text\" name=\"data\" id=\"data\" placeholder=\""+this.birthday+"\"/>\n" +
                    "                    <span >*</span>\n" +
                    "                </div>\n" +
                    "                <div>\n" +
                    "                    <label for=\"userphone\">联系电话：</label>\n" +
                    "                    <input type=\"text\" name=\"userphone\" id=\"userphone\" placeholder=\""+this.phone+"\"/>\n" +
                    "                    <span >*</span>\n" +
                    "                </div>\n" +
                    "                <div>\n" +
                    "                    <label for=\"userAddress\">用户地址：</label>\n" +
                    "                    <input type=\"text\" name=\"userAddress\" id=\"userAddress\" placeholder=\""+this.adeer+"\"/>\n" +
                    "                </div>\n" +
                    "                <div class=\"providerAddBtn\">\n" +
                    "                    <a href=\"javascript:void(0)\" onclick='UpdateAdminInfo("+this.iD+")'>保存</a>\n" +
                    "                    <a href=\"userList.html\">返回</a>\n" +
                    "                </div>\n" +
                    "            </form>")
            })
        })
    });

</script>


<body>
<!--头部-->
<header class="publicHeader">
    <h1>DR钻戒后台管理系统</h1>

    <div class="publicHeaderR">
        <a href="login.html">退出</a>
    </div>
</header>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器!</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <div class="left">
        <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
        <nav>
            <ul class="list">
                <li><a href="billList.html">订单管理</a></li>
                <li ><a href="providerList.html">商品管理</a></li>
                <li id="active"><a href="userList.html">用户管理</a></li>
                <li><a href="password.html">密码修改</a></li>
                <li><a href="login.html">退出系统</a></li>
            </ul>
        </nav>
    </div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户修改页面</span>
        </div>
        <div class="providerAdd">

        </div>

    </div>
</section>
<footer class="footer">
</footer>
<script src="js/time.js"></script>

</body>
</html>